package com.hengxinguotong.zhihuichengjian.ui;

import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.hengxinguotong.zhihuichengjian.R;
import com.hengxinguotong.zhihuichengjian.adapter.MyFragmentPagerAdapter;
import com.hengxinguotong.zhihuichengjian.fragment.HomeFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/7/21.
 */

public class HomeActivity extends BaseActivity {

    @BindView(R.id.home_vp)
    ViewPager homeVp;

    private HomeFragment homeFragment;
    private List<Fragment> fragments;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_homepage);
        ButterKnife.bind(this);
        initViewPager();
    }

    private void initViewPager(){
        fragments = new ArrayList<Fragment>();
        if(homeFragment == null){
            homeFragment = new HomeFragment();
            fragments.add(homeFragment);
        }
        homeVp.setAdapter(new MyFragmentPagerAdapter(getSupportFragmentManager(), fragments));
        homeVp.setCurrentItem(0);
    }
}
